package com.study.ojbackendjudgeservice.judege;


import com.study.ojbackendjudgeservice.judege.strategy.DefaultJudgeStrategyImpl;
import com.study.ojbackendjudgeservice.judege.strategy.JavaLanguageJudgeStrategyImpl;
import com.study.ojbackendjudgeservice.judege.strategy.JudgeContext;
import com.study.ojbackendjudgeservice.judege.strategy.JudgeStrategy;
import com.study.ojbackendmodel.codesandbox.JudgeInfo;
import com.study.ojbackendmodel.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * 判题管理（简化调用）
 */
@Service
public class JudgeManager {

    JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategyImpl();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategyImpl();
        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
